import os
import webapp2
#from google.appengine.ext import webapp
#import webapp2 as webapp
#os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
#from google.appengine.dist import use_library
#use_library('django', '1.1')

from rer import get_sign_link
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app


class MainHandler(webapp2.RequestHandler):  
    def get(self): 
        res = get_sign_link(self.request.uri)
        res['sub_title'] = 'JavaScript Regular Expressions Pattern Checker'
        TEMPLATE_DIR = 'template'
        path = os.path.join(os.path.dirname(__file__), TEMPLATE_DIR, 'checker.html')
        self.response.out.write( template.render(path, res) )


def main():
    application = webapp2.WSGIApplication([('/', MainHandler)], debug=True)
    run_wsgi_app(application)

if __name__ == '__main__':
    main()
